package cn.ithers.blog.controller.portal;

import cn.ithers.blog.response.ResponseResult;
import cn.ithers.blog.service.IEsArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zhanghuan
 * @date: 2020/8/28 17:51
 * @description:
 */
@Api(value = "搜索", tags = "搜索")
@RestController
@RequestMapping("/portal/search")
public class SearchPortalApi {

    @Autowired
    private IEsArticleService esArticleService;

    @ApiOperation("查询文章")
    @GetMapping
    public ResponseResult doSearch(@ApiParam("关键字") @RequestParam("keywords") String keywords,
                                   @ApiParam(value = "当前页码",required = true) @RequestParam("page") int page,
                                   @ApiParam(value = "每页显示条数",required = true) @RequestParam("pageSize") int pageSize,
                                   @ApiParam("分类ID") @RequestParam(value = "categoryId", required = false) String categoryId,
                                   @ApiParam("分类条件") @RequestParam(value = "sort", required = false) Integer sort) {
//        return solrService.doSearch(keywords,page,pageSize,categoryId,sort);
        return ResponseResult.SUCCESS("该模块正在优化中......");
    }

//    @GetMapping("/importAll")
    public int importAll() {
        return esArticleService.importAll();

    }
}
